package com.lfg.leetcode.leetcode0;

public class No80removeDuplicates {

    public static void main(String[] args) {
        int ret = removeDuplicates(new int[]{1, 1, 1, 2, 2, 2, 3});
        System.out.println("[" + ret + "]");
    }

    public static int removeDuplicates(int[] nums) {
        if (nums.length < 2) {
            return nums.length;
        }
        int length = 0;
        for (int i = 0; i < nums.length; i++) {
            if (length < 2 || nums[i] != nums[length - 2]) {
                nums[length++] = nums[i];
            }
        }
        return length;
    }

}

